<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui"            
        xmlns:c="http://java.sun.com/jsp/jstl/core"
	template="template.xhtml">
	
	<ui:define name="head">
            <h:outputScript library="primefaces/jquery" name="jquery.js"/>
            <script type="text/javascript">
                $(document).ready(function() {
                    $("#showComment").click(function () {
                        $("#comment").toggle("slow");
                    });
                });
            </script>
	</ui:define>

	<ui:define name="content">
            <h:form id="formRecado">
                
                <c:if test="${not empty amigoController.solicitacao}">
                    Solicitações                    
                </c:if>                
                
                    
                    <p:dataList id="listaSolicitacao" value="#{amigoController.solicitacao}" var="solicitacao" type="ordered">  
                        <p:column>
                            #{solicitacao.idPessoaDe.nome}
                        </p:column>
                        <p:column>                   
                            <p:growl id="growl" showDetail="true" sticky="true" >

                            <p:commandButton update="growl, listaSolicitacao"
                                             action="#{amigoController.aceitar}" ajax="false"
                                             image="ui-icon ui-icon-circle-check">
                                <f:setPropertyActionListener value="#{solicitacao}" target="#{amigoController.solicitacaoAmigo}"/>
                            </p:commandButton>
                             
                            <p:commandButton  
                                action="#{amigoController.recusar}" ajax="false"
                                             image="ui-icon ui-icon-circle-close"
                                             update="growl, listaSolicitacao">
                                <f:setPropertyActionListener value="#{solicitacao}" target="#{amigoController.solicitacaoAmigo}"/>
                            </p:commandButton>
                             
                            </p:growl>
                        </p:column>                    
                    </p:dataList>  
                      
                
                <c:forEach items="#{recadoController.recadoToUser()}" var="recado">                        
                    
                    <div class="post" >
                        
                        <div class="post_title"><h3><a href="#"><h:outputText value="#{recado.idPessoaDe.nome}"></h:outputText></a></h3></div>
                        
                            <div class="post_date">
                                Enviado em 
                                <h:outputText value="#{recado.dataCadastro}" >
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm"/>  
                                </h:outputText>
                                por <a href="#"><h:outputText value="#{recado.idPessoaDe.nome}"></h:outputText></a>
                            </div>

                            <div class="post_body">
                                <h:outputText value="#{recado.recado}"></h:outputText>
                            </div>
                         
                            <div class="post_meta">
                                    <a style="cursor: pointer" id="showComment">
                                        <h:outputText value="${comentarioController.comentarioByPost(1).size()}"></h:outputText> 
                                        comentários
                                    </a>
                            </div>                        
                        
                            <div id="comment" style="display: none">
                                
                            <c:forEach items="#{comentarioController.comentarioByPost(recado.id)}" var="comentario">
                            <div class="comment_list">
                                
                                <div class="comment alt">
                                    
                                    <div class="comment_gravatar left"><img alt="" src="sample-gravatar.jpg" height="32" width="32" /></div>

                                    <div class="comment_author left">
                                            <a href="#">
                                                <h:outputText value="#{comentario.idPessoa.nome}"></h:outputText> - 
                                                <h:outputText value="#{comentario.dataCadastro}" >
                                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm"/>  
                                                </h:outputText> 
                                            </a>                                                                                        
                                            <div class="comment_date">
                                            </div>
                                    </div>

                                    <div class="clearer"></div>

                                    <div class="comment_body">									
                                            <p><h:outputText value="#{comentario.comentario}"></h:outputText></p>
                                    </div>
                                    
                                </div>
                                
                            </div>  
                                
                            </c:forEach>
                                
                        </div>
                        
                    </div>
                </c:forEach>
            </h:form>                  
        </ui:define>
</ui:composition>
